﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="MinHeapTest.cs" company="pwasiewicz">
//   pwasiewicz
// </copyright>
// <summary>
//   Defines the MinHeapTest type.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace LogicSystem.Tests
{
    using LogicSystem.Helpers;
    using Microsoft.VisualStudio.TestTools.UnitTesting;

    /// <summary>The min heap test.</summary>
    [TestClass]
    public class MinHeapTest
    {
        /// <summary>Gets or sets the heap.</summary>
        public MinHeap<int, int> Heap { get; set; }
        
        /// <summary>
        /// Initializes context for a single test.
        /// </summary>
        [TestInitialize]
        public void Initialize()
        {
            this.Heap = new MinHeap<int, int>();
            
            this.Heap.Insert(1, 1);
            this.Heap.Insert(3, 3);
            this.Heap.Insert(0, 0);
            this.Heap.Insert(2, 2);
            this.Heap.Insert(0, 0);
        }

        /// <summary>
        /// Checking if minimum values is got properly.
        /// </summary>
        [TestMethod]
        public void GettingMinimumValue()
        {
            Assert.AreEqual(0, this.Heap.Remove().Value);
        }

        /// <summary>
        /// Checking if removing tops from heap works correctly.
        /// </summary>
        [TestMethod]
        public void RemovingTop()
        {
            this.Heap.Remove();
            this.Heap.Remove();

            Assert.AreEqual(1, this.Heap.Remove().Value);
        }

    }
}
